﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Data.SqlClient;

namespace FirmaTransportowa
{
    public partial class DriverActualTransportForm : Form
    {
        private DriverPanelPresenter presenter;

        public DriverActualTransportForm(DriverPanelPresenter presenter)
        {
            InitializeComponent();
            this.presenter = presenter;
        }

        private void finishTransport_Click(object sender, EventArgs e)
        {
            presenter.finishTransport();
        }

        private void processPackages_Click(object sender, EventArgs e)
        {
            presenter.processPackages();
        }

        public void showDataTable(Transport transport)
        {
            actualTransportPackages.Columns[0].HeaderText = "ID";
            if (transport.destination_city == "sortownia")
            {
                actualTransportPackages.Columns[1].HeaderText = "Imię nadawcy";
                actualTransportPackages.Columns[2].HeaderText = "Nazwisko nadawcy";
            }
            else
            {
                actualTransportPackages.Columns[1].HeaderText = "Imię odbiorcy";
                actualTransportPackages.Columns[2].HeaderText = "Nazwisko odbiorcy";
            }
            actualTransportPackages.Columns[3].HeaderText = "Kod pocztowy";
            actualTransportPackages.Columns[4].HeaderText = "Miejscowość";
            actualTransportPackages.Columns[5].HeaderText = "Ulica";
            actualTransportPackages.Columns[6].HeaderText = "Numer domu";
            actualTransportPackages.Columns[7].HeaderText = "Numer telefonu";
            actualTransportPackages.Columns[8].HeaderText = "Waga paczki";
            actualTransportPackages.Columns[9].HeaderText = "Data dodania paczki";
            actualTransportPackages.Columns[10].HeaderText = "Status";
            actualTransportPackages.Columns[0].Width = 65;
            actualTransportPackages.Columns[1].Width = 100;
            actualTransportPackages.Columns[2].Width = 100;
            actualTransportPackages.Columns[3].Width = 80;
            actualTransportPackages.Columns[4].Width = 120;
            actualTransportPackages.Columns[5].Width = 120;
            actualTransportPackages.Columns[6].Width = 80;
            actualTransportPackages.Columns[7].Width = 100;
            actualTransportPackages.Columns[8].Width = 80;
            actualTransportPackages.Columns[9].Width = 100;
            actualTransportPackages.Columns[10].Width = 100;
        }

        private void DriverActualTransportForm_HelpButtonClicked(object sender, CancelEventArgs e)
        {
            HelpUtils.showHelp(this, 8);
        }

        protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
        {
            if (keyData == Keys.F1)
            {
                HelpUtils.showHelp(this, 8);
                return true;
            }
            return base.ProcessCmdKey(ref msg, keyData);
        }
    }
}